import { createWebHashHistory, createRouter } from 'vue-router'
import ProjectPage from '@render/pages/project/ProjectPage.vue'
const routes = [
  // { path: '/', component: HomeView },
  // { path: '/about', component: () => import('./views/UserDetails.vue') },
  { name: 'ProjectPage', path: '/', component: ProjectPage },
  {
    name: 'ApiPage',
    path: '/api-info/:projectId',
    component: () => import('@render/pages/api/ApiPage.vue'),
  },
]

export const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

router.beforeEach(async (to, from, next) => {
  if (!window.API_PREFIX) {
    window.API_PREFIX = await window.electron.getApiPrefix()
  }
  next()
})
